#include "BlurViewComponentInstance.h"
#include "BlurPackage.h"
#include "RNOH/arkui/ImageNode.h"

namespace rnoh {

BlurViewComponentInstance::BlurViewComponentInstance(Context context) : CppComponentInstance(std::move(context))
{
    DLOG(INFO) << "[BlurViewComponentInstance] Props->blurType: " << std::string("start...");
}

void BlurViewComponentInstance::onPropsChanged(SharedConcreteProps const &props)
{
    CppComponentInstance::onPropsChanged(props);
    if (props == nullptr) {
        return;
    }
    m_blurNode.SetBlurType(props->blurType, props->blurAmount);
}

BlurViewNode &BlurViewComponentInstance::getLocalRootArkUINode() { return m_blurNode; }

void BlurViewComponentInstance::onChildInserted(
    ComponentInstance::Shared const& childComponentInstance, std::size_t index)
{
    DLOG(INFO) << "BlurViewComponentInstance onChildInserted";
    m_blurNode.InsertChild(childComponentInstance->getLocalRootArkUINode(), index);
};

void BlurViewComponentInstance::onChildRemoved(ComponentInstance::Shared const& childComponentInstance)
{
    DLOG(INFO) << "BlurViewComponentInstance onChildRemoved";
    m_blurNode.RemoveChild(childComponentInstance->getLocalRootArkUINode());
};

} // namespace rnoh